const express = require("express");
const userinfoHandler = require("../handler/userinfo");
const router = express.Router();

// 导入验证规则
const expressJoi = require("@escook/express-joi");
const {
  updateUserInfoSchema,
  updatePwdSchema,
  updateAvatarSchema,
} = require("../schema/user");

// 获取用户信息
router.get("/userinfo", userinfoHandler.getUserInfo);
// 更新用户信息
router.post(
  "/userinfo",
  expressJoi(updateUserInfoSchema),
  userinfoHandler.updateUserInfo
);
// 更新密码
router.post(
  "/updatepwd",
  expressJoi(updatePwdSchema),
  userinfoHandler.updatePassWord
);

// 更换头像
router.post(
  "/update/avatar",
  expressJoi(updateAvatarSchema),
  userinfoHandler.updateAvatar
);
module.exports = router;
